package com.sinosoft.oms.service.impl;

import com.sinosoft.oms.dto.OrderBean;
import com.sinosoft.oms.entity.oms.Appnt;
import com.sinosoft.oms.entity.oms.Insured;
import com.sinosoft.oms.entity.oms.Order;
import com.sinosoft.oms.entity.oms.Product;
import com.sinosoft.oms.service.OrderService;
import com.sinosoft.oms.service.BasicInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.sql.SQLException;



/**
 * @author:Frankiegg
 * @Date:2018/5/7
 * @project:bee
 * @Modified By:
 **/
@Service("DealBasicInfo")
public class BasicInfoServiceImpl implements BasicInfoService {

    @Autowired
    private OrderService orderService;

    @Override
    public boolean postBasicInfo(Order order, Appnt appnt, Insured insured, Product product) throws SQLException{
        boolean clientResult=true;

        if (!orderService.insertOrder(order,appnt,insured,product)){
            clientResult=false;
        }
        return clientResult;
    }

    @Override
    public boolean deleteBasicInfo(String orderId) throws SQLException{
        boolean clientResult=true;

        if (!orderService.deleteOrder(orderId)){
            clientResult=false;
        }
        return clientResult;
    }

    @Override
    public boolean updateBasicInfo(Order order, Appnt appnt, Insured insured, Product product) {
        boolean clientResult=true;

        if (!orderService.updateOrder(order,appnt,insured,product)){
            clientResult=false;
        }
        return clientResult;
    }

    @Override
    public OrderBean findOrderBasicInfo(String orderId) {
        boolean clientResult=true;

        if (StringUtils.isEmpty(orderService.findByOrderId(orderId))){
            clientResult=false;
        }
        return null;
    }
}
